package com.syni.mdd.sjb.community.base.controller;

import com.syni.mdd.sjb.community.base.entity.dto.PageDTO;
import com.syni.mdd.sjb.community.base.service.SjbQywxExternalUserRefService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.Map;

/**
 * @author wangbaitao
 * @version 1.0.0
 * <h>企业(客户信息)controller</h>
 * @Date 2021/2/24
 **/
@RestController
@RequestMapping("user")
public class SjbQywxUserDataController {

    @Autowired
    private SjbQywxExternalUserRefService sjbQywxExternalUserRefService;

    /**
     * 根据userid进行当前管理员的用户数据同步
     *
     * @param sjbUserId 数据宝用户Id
     * @param userid    企业微信用户id
     * @return 同步结果
     */
    @PostMapping("syncData")
    public Map<String, Object> syncData(@RequestParam("sjbUserId") String sjbUserId,
                                        @RequestParam("userid") String userid,
                                        @RequestParam("corpid") String corpid) {
        return sjbQywxExternalUserRefService.syncData(sjbUserId, userid,corpid);
    }

    /**
     * 客户数据列表查询结果
     *
     * @param pageDTO 分页查询条件对象
     * @return 查询结果
     */
    @PostMapping("queryDataByParam")
    public Map<String, Object> queryDataByParam(@RequestBody @Valid PageDTO pageDTO) {
        return sjbQywxExternalUserRefService.queryDataByParam(pageDTO);
    }

    /**
     * 根据外部联系人id精确查询客户数据，主要用户页面跳转
     *
     * @param externalUserId 外部联系人id
     * @return 查询结果
     */
    @GetMapping("getUserDataById")
    public Map<String, Object> getUserDataById(@RequestParam("externalUserId") String externalUserId) {
        return sjbQywxExternalUserRefService.getUserDataById(externalUserId);
    }

    /**
     * 根据企业id获取添加人集合
     *
     * @param corpId 企业Id
     * @return 查询结果
     */
    @GetMapping("getAddUsers")
    public Map<String, Object> getAddUsers(@RequestParam("corpId") String corpId) {
        return sjbQywxExternalUserRefService.getAddUsers(corpId);
    }
}
